package com;

public class TestNull {
	public static void main(String[] args) {
		String a = "2022/3/27";
		String b = "2022/12/27";
		System.out.println(a.compareTo(b));
		String[] aarr = a.split("/");
		System.out.println(aarr[0]+"-"+formatMd(aarr[1])+"-"+formatMd(aarr[2]));
		
		String ss = "ABC,";
		System.out.println(ss.substring(0, ss.length() - 1));
		
		String box = null;
		String tuo = null;
		System.out.println("都空");
		validata(box, tuo);

		box = "22";
		tuo = null;
		System.out.println("box不空");
		validata(box, tuo);

		box = null;
		tuo = "12";
		System.out.println("tuo不空");
		validata(box, tuo);

		box = "122";
		tuo = "12";
		System.out.println("tuo box 不空,且不一样");
		validata(box, tuo);

		box = "122";
		tuo = "122";
		System.out.println("tuo box 不空,且一样");
		validata(box, tuo);
	}

	private static String formatMd(String data) {
		return data.length()==1?"0"+data : data;
	}

	private static void validata(String box, String tuo) {
		if (box != null && !box.equals(tuo)) {
			System.out.println("不一样");
		} else if (tuo != null && !tuo.equals(box)) {
			System.out.println("不一样");
		} else {
			System.out.println("一样");
		}

	}
}
